﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace wathammer40kListBuilder
{
    /// <summary>
    /// Interaction logic for ModalWindow.xaml
    /// </summary>
    public partial class ModalWindow : Window
    {
        public ModalWindow()
        {
            InitializeComponent();
        }

        public void AddPanel(UserControl newPanel)
        {
            Closable cl = newPanel as Closable;
            if (cl == null) throw new Exception() ;
            
            ModalPanel mp = new ModalPanel();
            cl.panel = mp;
            mainPanel.Children.Clear();
            mainPanel.Children.Add(newPanel);
           
            mp.EndAction += (s, e) => 
            {
                this.Close();
            };
        }
    }
}
